var map = null;
var map1 = null;
var map2;
var markers = [];
function initialize(zom) {
	var mapOptions = {
		zoom : zom,
		center : new google.maps.LatLng(21.039326, 105.850153),
		disableDefaultUI : true,
		mapTypeId : google.maps.MapTypeId.ROADMAP,
	};
	map = new google.maps.Map(document.getElementById('mapdetailpost'),
			mapOptions);
	map
	.setOptions({
		draggableCursor : "url(http://s3.amazonaws.com/besport.com_images/status-pin.png), auto"
	});
	
	google.maps.event.addListener(map, 'click', function(event) {
		clearOverlays();
		addMarker(event.latLng);
		$('#latitude').val(event.latLng.lat());
		$('#longitude').val(event.latLng.lng());
	});

}
var myLatlng = null;
function initialize1(zom) {
	var x = document.getElementById("city");
	var y = x.options[x.selectedIndex].value;
	if (y == 1) {
		myLatlng = new google.maps.LatLng(21.037403, 105.849981);
	}
	if (y == 2) {
		myLatlng = new google.maps.LatLng(10.842748, 106.631126);
	}
	if (y == 0) {
		myLatlng = new google.maps.LatLng(21.037403, 105.849981);
		zom = 6;
	}
	var mapOptions = {
		zoom : zom,
		center : myLatlng,
		disableDefaultUI : true,
		mapTypeId : google.maps.MapTypeId.ROADMAP,
	};
	
	
	
	map1 = new google.maps.Map(document.getElementById('mapdetailpost'),
			mapOptions);
	map1
	.setOptions({
		draggableCursor : "url(http://s3.amazonaws.com/besport.com_images/status-pin.png), auto"
	});
	
	google.maps.event.addListener(map1, 'click', function(event) {
		clearOverlays();
		addMarker1(event.latLng);
		$('#latitude').val(event.latLng.lat());
		$('#longitude').val(event.latLng.lng());
	});

}

//city1
function initializek(zom) {
	var x = document.getElementById("city1");
	var y = x.options[x.selectedIndex].value;
	if (y == 1) {
		myLatlng = new google.maps.LatLng(21.037403, 105.849981);
	}
	if (y == 2) {
		myLatlng = new google.maps.LatLng(10.842748, 106.631126);
	}
	if (y == 0) {
		myLatlng = new google.maps.LatLng(21.037403, 105.849981);
		zom = 6;
	}
	var mapOptions = {
		zoom : zom,
		center : myLatlng,
		disableDefaultUI : true,
		mapTypeId : google.maps.MapTypeId.ROADMAP,
	};
	
	
	
	map1 = new google.maps.Map(document.getElementById('mapdetailpost'),
			mapOptions);
	map1
	.setOptions({
		draggableCursor : "url(http://s3.amazonaws.com/besport.com_images/status-pin.png), auto"
	});
	
	google.maps.event.addListener(map1, 'click', function(event) {
		clearOverlays();
		addMarker1(event.latLng);
		$('#latitude').val(event.latLng.lat());
		$('#longitude').val(event.latLng.lng());
	});

}
//--------

var districtLatlng = null;
function initialize2(zom) {
	var x = document.getElementById("district");
	var y = x.options[x.selectedIndex].value;
	if (y == 1) {
		districtLatlng = new google.maps.LatLng(21.037723, 105.825964);
	}
	if (y == 2) {
		districtLatlng = new google.maps.LatLng(21.028911, 105.855662);
	}
	if (y == 3) {
		districtLatlng = new google.maps.LatLng(21.075851, 105.822518);
	}
	if (y == 4) {
		districtLatlng = new google.maps.LatLng(21.020018, 105.885016);
	}
	if (y == 5) {
		districtLatlng = new google.maps.LatLng(21.04397, 105.787328);
	}
	if (y == 6) {
		districtLatlng = new google.maps.LatLng(21.016253, 105.82681);
	}
	if (y == 7) {
		districtLatlng = new google.maps.LatLng(21.005195, 105.855147);
	}
	if (y == 8) {
		districtLatlng = new google.maps.LatLng(20.974904, 105.86352);
	}
	if (y == 9) {
		districtLatlng = new google.maps.LatLng(20.997343, 105.81136);
	}
	if (y == 10) {
		districtLatlng = new google.maps.LatLng(20.957272, 105.755914);
	}
	if (y == 11) {
		districtLatlng = new google.maps.LatLng(21.163923, 105.849641);
	}
	if (y == 12) {
		districtLatlng = new google.maps.LatLng(21.054385, 105.746447);
	}
	if (y == 0) {
		districtLatlng = new google.maps.LatLng(21.037403, 105.849981);
	}
	var mapOptions = {
		zoom : zom,
		center : districtLatlng,
		disableDefaultUI : true,
		mapTypeId : google.maps.MapTypeId.ROADMAP,
	};
	map2 = new google.maps.Map(document.getElementById('mapdetailpost'),
			mapOptions);
	map2
			.setOptions({
				draggableCursor : "url(http://s3.amazonaws.com/besport.com_images/status-pin.png), auto"
			});
	google.maps.event.addListener(map2, 'click', function(event) {
		clearOverlays();
		addMarker2(event.latLng);
		$('#latitude').val(event.latLng.lat());
		$('#longitude').val(event.latLng.lng());
	});

}
function initialize3(zom) {
	var x = document.getElementById("district");
	var y = x.options[x.selectedIndex].value;
	if (y == 1) {
		districtLatlng = new google.maps.LatLng(21.037723, 105.825964);
	}
	if (y == 2) {
		districtLatlng = new google.maps.LatLng(21.028911, 105.855662);
	}
	if (y == 3) {
		districtLatlng = new google.maps.LatLng(21.075851, 105.822518);
	}
	if (y == 4) {
		districtLatlng = new google.maps.LatLng(21.020018, 105.885016);
	}
	if (y == 5) {
		districtLatlng = new google.maps.LatLng(21.04397, 105.787328);
	}
	if (y == 6) {
		districtLatlng = new google.maps.LatLng(21.016253, 105.82681);
	}
	if (y == 7) {
		districtLatlng = new google.maps.LatLng(21.005195, 105.855147);
	}
	if (y == 8) {
		districtLatlng = new google.maps.LatLng(20.974904, 105.86352);
	}
	if (y == 9) {
		districtLatlng = new google.maps.LatLng(20.997343, 105.81136);
	}
	if (y == 10) {
		districtLatlng = new google.maps.LatLng(20.957272, 105.755914);
	}
	if (y == 11) {
		districtLatlng = new google.maps.LatLng(21.163923, 105.849641);
	}
	if (y == 12) {
		districtLatlng = new google.maps.LatLng(21.054385, 105.746447);
	}
	if (y == 0) {
		districtLatlng = new google.maps.LatLng(21.037403, 105.849981);
	}
	var latitude = document.getElementById("latitude").value;

	var longitude = document.getElementById("longitude").value;
	var latLng = new google.maps.LatLng(latitude, longitude);
	var mapOptions = {
		zoom : zom,
		center : latLng,
		disableDefaultUI : true,
		mapTypeId : google.maps.MapTypeId.ROADMAP,
	};
	map2 = new google.maps.Map(document.getElementById('mapdetailpost'),
			mapOptions);
	map2
			.setOptions({
				draggableCursor : "url(http://s3.amazonaws.com/besport.com_images/status-pin.png), auto"
			});

	addMarker2(latLng);
	google.maps.event.addListener(map2, 'click', function(event) {
		clearOverlays();
		addMarker2(event.latLng);
		$('#latitude').val(event.latLng.lat());
		$('#longitude').val(event.latLng.lng());
	});

}
function addMarker(location) {
	marker = new google.maps.Marker({
		position : location,
		map : map
	});
	markers.push(marker);
}
function addMarker1(location) {
	marker = new google.maps.Marker({
		position : location,
		map : map1
	});
	markers.push(marker);
}
function addMarker2(location) {
	marker = new google.maps.Marker({
		position : location,
		map : map2
	});
	markers.push(marker);
}
function clearOverlays() {
	setAllMap(null);
}
function setAllMap(map2) {
	for ( var i = 0; i < markers.length; i++) {
		markers[i].setMap(map2);
	}
}